# 取符合要求数字
# 注意：此题每个数字后面都有
x=eval(input())

i = 1
j = 0
k = 0
count = 0
while i <= x:
    while j <= x:
        while k <= x:
            if i != j and j != k and i != k:
                if count % 10 == 9:
                    print("{}{}{}".format(i, j, k), end=" \n")
                else:
                    print("{}{}{}".format(i, j, k), end=" ")
                count += 1
            k += 1
        j += 1
        k = 0
    i += 1
    j = 0
    k = 0